#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QFile>
#include <QMainWindow>
#include <QThread>

//#include <qt_windows.h>
#include "global.h"
#include "optionset.h"
#include "myserialport.h"


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:

    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void init();
    void init_cmb_sp();

protected:
    //bool nativeEvent(const QByteArray& eventType, void* message, long* result) override;//监控Windows系统事件（硬件热插拔）
    int getSPSetting(MySerialPortSettings &);
    void setSPContolStatus(bool v);
private slots:
    void slSPReceiveData(const QByteArray data);
    void on_btn_send_clicked();
    void on_btn_oc_clicked();

    void on_chk_hexreceive_clicked(bool checked);

signals:
    void sgSendData(const QByteArray data);
private:
    Ui::MainWindow *ui;
    MySerialPort * _msp;
    bool _isHex=true;
    QFile _file;
};
#endif // MAINWINDOW_H
